package ifi.sma.group5.models;

import ifi.sma.group5.db.Db;

import java.util.ArrayList;
import java.util.Map;





public class EtudiantModel {
	
		public int IdEtudiant = -1;
		public String NomEtudiant;
		public String MotdepasseEtudiant;
		public String DescriptionEtudiant;
		
		public EtudiantModel() {
		}
		public EtudiantModel(String NomEtudiant) {
			if (NomEtudiant.equals(""))
				return;
			try {
				//AID = name;
				//name = name.substring(0, name.indexOf("@"));
				Db db = new Db("Etudiant");
				ArrayList<Map<String, String>> datas = db.get(
						"SELECT * FROM Etudiant WHERE NomEtudiant=?", NomEtudiant);
				if (datas.size() > 0) {
					this.IdEtudiant = Integer.parseInt(datas.get(0).get("IdEtudiant"));
					this.NomEtudiant = datas.get(0).get("NomEtudiant");
					this.MotdepasseEtudiant = datas.get(0).get("MotdepasseEtudiant");
					this.DescriptionEtudiant = datas.get(0).get("DescriptionEtudiant");
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
}
